package com.googlecode.erebos.server;

import com.googlecode.erebos.Size;
import com.sun.sgs.app.AppContext;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * The MIT License
 * <p/>
 * Copyright (c) 2009 Malachi de AElfweald (malachid@gmail.com)
 * <p/>
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * <p/>
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * <p/>
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
public class SizeImpl
implements Size, Serializable
{
    /** The version of the serialized form of this class. */
    private static final long serialVersionUID = 1L;

    private BigDecimal height, width, depth, weight;

    public SizeImpl()
    {
        height = BigDecimal.ZERO;
        width = BigDecimal.ZERO;
        depth = BigDecimal.ZERO;
        weight = BigDecimal.ZERO;
    }

    /**
     * Note: The average height of an adult human is 1.5 to 1.8 meters (5-6 feet)
     *
     * @return height in meters
     */
    public BigDecimal getHeight() {
        return height;
    }

    public void setHeight(BigDecimal height)
    {
        AppContext.getDataManager().markForUpdate(this);
        this.height = height;
    }

    /**
     * @return width in meters
     */
    public BigDecimal getWidth() {
        return width;
    }

    public void setWidth(BigDecimal width)
    {
        AppContext.getDataManager().markForUpdate(this);
        this.width = width;
    }

    /**
     * @return depth in meters
     */
    public BigDecimal getDepth() {
        return depth;
    }

    public void setDepth(BigDecimal depth)
    {
        AppContext.getDataManager().markForUpdate(this);
        this.depth = depth;
    }

    /**
     * Note: The average weight of an adult human is 76-83 kg (163-183 lbs) for males
     * and 54-64 kg (120-140 lbs) for females
     *
     * @return weight in kilograms
     */
    public BigDecimal getWeight() {
        return weight;
    }

    public void setWeight(BigDecimal weight)
    {
        AppContext.getDataManager().markForUpdate(this);
        this.weight = weight;        
    }
}
